/**
 * 
 */
package cn.edu.tyu.finance.thingstype.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.edu.tyu.finance.thingstype.domain.Users;
import cn.edu.tyu.finance.util.DbUtil;

/**
 * @author Dell
 *
 */
public class UserDaoImpl {
	public int addUser(Users users) throws SQLException{
		Connection conn = DbUtil.getConnection();
		String sql = "insert into users values(?,?,?)";
		PreparedStatement ps = conn.prepareStatement(sql);
		ps.setString(1, users.getUserid());
		ps.setString(2, users.getUsername());
		ps.setString(3, users.getUserpsw());
		int res = ps.executeUpdate();
		DbUtil.backConn(conn, ps, null);
		return res;
	}
	public static void main(String[] args) throws SQLException {
		UserDaoImpl userDao = new UserDaoImpl();
		Users users = new Users();
		users.setUserid("1");
		users.setUsername("zs");
		users.setUserpsw("123456");
		int res = userDao.addUser(users);
		System.out.print("res="+res);
	}
}
